<template>
	<!-- 筛选 -->
	<view v-if="showMask" class="search_box" @tap.stop="close">
		<view @tap.stop="" :class="{'search_child_box':true,'search_box_transform':showTransform}">
			<view class="search_title">
				筛选
			</view>
			<view class="search_main">
				<slot></slot>
			</view>
			<view class="submit_btn">
				<u-button text="重置" @click="onRefresh"></u-button>
				<u-button text="确定" @click="onAgree"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			show: {
				default: false,
				type: Boolean
			} //显示

		},
		data() {
			return {
				showMask: false,
				showTransform: false
			}
		},
		watch: {
			show(val) {
				if (val) {
					this.showMask = val
					setTimeout(() => {
						this.showTransform = val
					}, 100)
				} else {
					this.showTransform = val
					setTimeout(() => {
						this.showMask = val
					}, 300)
				}
			},
		},
		methods: {
			// 关闭筛选
			close() {
				this.$emit('update:show', false)
			},
			onRefresh() {
				this.$emit('onRefresh')
			},
			onAgree() {
				this.$emit('onAgree')
			}
		}
	}
</script>
<style scoped lang="scss">
	// 筛选
	.search_box {
		position: fixed;
		top: 0;
		right: 0;
		left: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: flex-end;
		z-index: 999;

		/deep/ .my_search_btn {
			display: inline-block;
			width: 132rpx;
			height: 60rpx;
			line-height: 60rpx;
			font-size: 26rpx;
			text-align: center;
			margin: 0;
			border: none;
		}

		.search_btns {

			display: flex;
			flex-wrap: wrap;

			.my_search_btn {
				margin-right: 8rpx;
			}
		}

		.my_search_btn {
			background-color: #F5F6FA;
			color: #666666;
			margin: 0 10rpx 10rpx 0;
			cursor: pointer;
			border-radius: 8rpx;

			&:nth-child(4n) {
				margin-right: 0;
			}
		}

		.check-btn {
			background-color: #4070FF;
			color: #fff;
		}

		.search_child_box {
			background: #fff;
			width: 624rpx;
			min-height: 100vh;
			overflow: auto;
			transform: translateX(100%);
			transition-duration: 300ms;
			font-weight: bold;
			font-size: 28rpx;
			position: relative;
			padding-bottom: calc(2rpx + env(safe-area-inset-bottom));
			padding-bottom: calc(2rpx + constant(safe-area-inset-bottom));
			display: flex;
			flex-direction: column;

			/deep/ .submit_btn {
				display: flex;
				width: 100%;
				box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.1);

				button {
					flex: 1 !important;
					height: 80rpx !important;
					font-weight: 400;
					font-size: 34rpx !important;
					border-radius: 0;
					border: none;
				}

				button:last-child {
					background: #4070FF;
					color: #fff;
				}
			}
		}

		.search_title {
			color: #333;
			border-left: 6rpx solid #4070FF;
			font-size: 28rpx;
			line-height: 28rpx;
			padding-left: 12rpx;
			margin: 32rpx;
		}

		.search_main {
			width: 100%;
			border-top: 1rpx solid #ebecef;
			padding: 32rpx 32rpx 0;
			color: #333;
			font-size: 28rpx;
			font-weight: 400;
			flex: 1;
			height: 0;
			overflow: auto;
			.thsc {
				display: flex;
				align-items: center;
				line-height: 60rpx;
				margin: 24rpx 0;
			}

			.ipt {
				width: 132rpx;
				height: 60rpx;
				background: #F5F6FA;
				margin-right: 10rpx;
				text-align: center;
				font-size: 24rpx;
			}

			.content_box {
				display: flex;
				margin: 24rpx 0;
				flex-direction: column;
			}

			.thsj {
				display: flex;
				justify-content: space-between;
				background: #F5F6FA;
				height: 60rpx;
				padding: 0 24rpx;
			}

			.thsj:first-child {
				margin: 0 0 24rpx 0;
			}

			.leng_ipt {
				height: 60rpx;
				background: #F5F6FA;
				font-size: 24rpx;
				padding-left: 24rpx;
			}
		}

		.search_box_transform {
			transform: translateX(0);
			transition-duration: 300ms;
		}
	}
</style>
